<?php

switch ($view) {
	case 'update':
		$PreparedTemplates['update']=doUpdate();
		$filename = 'view//update.php';
		include_once 'view//template.php';
		break;

	case 'showForm':
		switch ($viewRequest['type']) {
			case 'proxy':
				switch ($viewRequest['form']) {
					case '1':
						$PreparedTemplates['ip_list']=getIPlist();
						$PreparedTemplates['form']=1;
						$filename = 'view/proxy/form_ip_1.php';
						include_once 'view//template.php';
						break;
					case '2':
						$PreparedTemplates['ip_list']=getIPlist();
						$PreparedTemplates['form']=2;
						$filename = 'view//proxy/form_ip_2.php';
						include_once 'view//template.php';
						break;
					case '3':
						$PreparedTemplates['ip_list']=getIPlist();
						$PreparedTemplates['form']=3;
						$filename = 'view//proxy/form_ip_1.php';
						include_once 'view//template.php';
						break;
		}
				break;
				
			case 'radius':
				switch ($viewRequest['form']) {
					case '1':
						$PreparedTemplates['form']=1;
						$filename = 'view/radius/radius_form1.php';
						include_once 'view//template.php';
						break;
					case '2':
						$PreparedTemplates['form']=2;
						$filename = 'view/radius/radius_form1.php';
						include_once 'view//template.php';
						break;
					case '3':
						$PreparedTemplates['form']=3;
						$filename = 'view/radius/radius_form1.php';
						include_once 'view//template.php';
						break;
				}
				break;
				
			case 'failed':
					$PreparedTemplates['form']=1;
					$filename = 'view/failed/failed_form1.php';
					include_once 'view//template.php';
				break;
				
			case 'passed':
				switch ($viewRequest['form']) {
					case '1':
						$PreparedTemplates['form']=1;
						$filename = 'view/passed/passed_form1.php';
						include_once 'view//template.php';
						break;
					case '2':
						$PreparedTemplates['form']=2;
						$filename = 'view/passed/passed_form1.php';
						include_once 'view//template.php';
						break;
				}
				break;
				
			case 'tacacs':
				switch ($viewRequest['form']) {
					case '1':
						$PreparedTemplates['form']=1;
						$filename = 'view/tacacs/tacacs_form1.php';
						include_once 'view//template.php';
						break;
					case '2':
						$PreparedTemplates['form']=2;
						$filename = 'view/tacacs/tacacs_form1.php';
						include_once 'view//template.php';
						break;
				}
			break;
		}
		break;
		
	case 'processForm':
		switch ($viewRequest['type']) {
			
			case 'proxy':
				switch ($viewRequest['form']) {
		
					case '1':
						$PreparedTemplates['date_start']=$viewRequest['date_start'];
						$PreparedTemplates['date_end']=$viewRequest['date_end'];
						$PreparedTemplates['length']=$viewRequest['length'];
						if($viewRequest['ip']=="all")
							{$PreparedTemplates['report_form']=visitedSites_all($viewRequest['date_start'],$viewRequest['date_end'],$viewRequest['length']);
							}
						else	
						$PreparedTemplates['report_form']=visitedSites_ip($viewRequest['date_start'],$viewRequest['date_end'],$viewRequest['ip'],$viewRequest['length']);
						if(empty($PreparedTemplates['report_form']))
							$PreparedTemplates['report_form']['empty']='Нет совпадений! Выберите другие параметры.';
						$filename = 'view//proxy/report_form1_5.php';
						include_once 'view//template.php';
						break;
		
					case '2':
						$PreparedTemplates['date_start']=$viewRequest['date_start'];
						$PreparedTemplates['date_end']=$viewRequest['date_end'];
						$PreparedTemplates['length']=$viewRequest['length'];
						if($viewRequest['ip']=="all")
							{$PreparedTemplates['report_form']=timeVisiting_all($viewRequest['domain'], $viewRequest['date_start'],$viewRequest['date_end'],$viewRequest['length']);
							}
						else
						$PreparedTemplates['report_form']=timeVisiting_ip($viewRequest['ip'], $viewRequest['domain'],$viewRequest['date_start'],$viewRequest['date_end'],$viewRequest['length']);
						if(empty($PreparedTemplates['report_form'])) 
							$PreparedTemplates['report_form']['empty']='Нет совпадений! Выберите другие параметры.';
						$filename = 'view//proxy/report_form2_4.php';
						include_once 'view//template.php';
						break;
		
					case '3':
						$PreparedTemplates['date_start']=$viewRequest['date_start'];
						$PreparedTemplates['date_end']=$viewRequest['date_end'];
						$PreparedTemplates['length']=$viewRequest['length'];
						if($viewRequest['ip']=='all')
							{$PreparedTemplates['report_form']=trafic_all($viewRequest['date_start'],$viewRequest['date_end'],$viewRequest['length']);
							}
						else
						{$PreparedTemplates['report_form']=trafic_ip($viewRequest['date_start'],$viewRequest['date_end'],$viewRequest['ip'],$viewRequest['length']);}
						if(empty($PreparedTemplates['report_form'])) 
							$PreparedTemplates['report_form']['empty']='Нет совпадений! Выберите другие параметры.';
						$filename = 'view//proxy/report_form3.php';
						include_once 'view//template.php';
						break;
		
					}
				break;
				
			case 'radius':
				switch ($viewRequest['form']) {
		
					case '1':
						$PreparedTemplates['report_form']=RadiusRemoteAccessList($viewRequest['date_start'],$viewRequest['date_end']);
						if(empty($PreparedTemplates['report_form']))
							$PreparedTemplates['report_form']['empty']='Нет совпадений! Выберите другие параметры.';
						$filename = 'view//radius/report.php';
						include_once 'view//template.php';
						break;
		
					case '2':
						$PreparedTemplates['report_form']=Radius802List($viewRequest['date_start'], $viewRequest['date_end']);
						if(empty($PreparedTemplates['report_form'])) 
							$PreparedTemplates['report_form']['empty']='Нет совпадений! Выберите другие параметры.';
						$filename = 'view//radius/report.php';
						include_once 'view//template.php';
						break;
		
					case '3':
						$PreparedTemplates['report_form']=RadiusAdminAccessList($viewRequest['date_start'],$viewRequest['date_end']);
						if(empty($PreparedTemplates['report_form'])) 
							$PreparedTemplates['report_form']['empty']='Нет совпадений! Выберите другие параметры.';
						$filename = 'view//radius/report.php';
						include_once 'view//template.php';
						break;
				}
				
				break;
				
			case 'failed':
				$PreparedTemplates['report_form']=FailedNonTelephoneList($viewRequest['date_start'],$viewRequest['date_end']);
				if(empty($PreparedTemplates['report_form'])) 
							$PreparedTemplates['report_form']['empty']='Нет совпадений! Выберите другие параметры.';
						$filename = 'view//failed/report.php';
						include_once 'view//template.php';
						break;
				
			case 'passed':
				switch ($viewRequest['form']) {
		
					case '1':
						$PreparedTemplates['report_form']=PassedSoNetList($viewRequest['date_start'],$viewRequest['date_end']);
						if(empty($PreparedTemplates['report_form']))
							$PreparedTemplates['report_form']['empty']='Нет совпадений! Выберите другие параметры.';
						$filename = 'view//passed/report.php';
						include_once 'view//template.php';
						break;
		
					case '2':
						$PreparedTemplates['report_form']=PassedRemoteAccessList($viewRequest['date_start'], $viewRequest['date_end']);
						if(empty($PreparedTemplates['report_form'])) 
							$PreparedTemplates['report_form']['empty']='Нет совпадений! Выберите другие параметры.';
						$filename = 'view//passed/report.php';
						include_once 'view//template.php';
						break;
				}
				break;
				
			case 'tacacs':
		switch ($viewRequest['form']) {
		
					case '1':
						$PreparedTemplates['report_form']=TacacsTTYList($viewRequest['date_start'],$viewRequest['date_end']);
						if(empty($PreparedTemplates['report_form']))
							$PreparedTemplates['report_form']['empty']='Нет совпадений! Выберите другие параметры.';
						$filename = 'view//tacacs/report.php';
						include_once 'view//template.php';
						break;
		
					case '2':
						$PreparedTemplates['report_form']=TacacsCustomList($viewRequest['date_start'], $viewRequest['date_end']);
						if(empty($PreparedTemplates['report_form'])) 
							$PreparedTemplates['report_form']['empty']='Нет совпадений! Выберите другие параметры.';
						$filename = 'view//tacacs/report.php';
						include_once 'view//template.php';
						break;
				}
				break;
		}

	case 'report':
		switch ($viewRequest['report_type']){
			case 1:
				$PreparedTemplates['report_sites'] = VisitedSites();
				$filename = 'view//report.php';
				include_once 'view//template.php';
				break;
			case 2:
				$PreparedTemplates['report_traffic'] = IPTraffic();
				$filename = 'view//somereport.php';
				include_once 'view//template.php';
				break;
		}
		break;
		
	case 'drop':
		$PreparedTemplates['drop'] = CheckingDate();
		$filename = 'view//drop.php';
		include_once 'view//template.php';
		break;
	
	case 'dropall':
		$PreparedTemplates['drop'] = DeleteAll();
		$filename = 'view//drop.php';
		include_once 'view//template.php';
		break;
	
	default:
		$filename = 'view//null.php';
		include_once 'view//template.php';
		break;

		
}
?>